<template>
	<div>
		<el-form :inline="true" :model="formInline" class="user-search">
			<el-form-item label=""><el-input size="small" v-model="formInline.shipinbianhao" placeholder="输入课程编号"></el-input></el-form-item>
			<el-form-item label=""><el-input size="small" v-model="formInline.shipinmingcheng" placeholder="输入课程名称"></el-input></el-form-item>
			<el-form-item styxlexulxie5 prop="leibie"
				><el-select size="small" v-model="formInline.leibie" placeholder="请选择"
					><el-option selected label="请选择" value=""></el-option
					><el-option v-for="item in shipinleibies" :key="item.leibie" :label="item.leibie" :value="item.leibie"></el-option></el-select
			></el-form-item>

			<el-form-item>
				<el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
			</el-form-item>
		</el-form>
		<el-table
			size="small"
			:data="listData"
			highlight-current-row
			v-loading="loading"
			border
			element-loading-text="拼命加载中"
			@selection-change="handleSelectionChange"
		>
			<el-table-column align="center" type="selection" width="60"></el-table-column>
			<el-table-column sortable prop="shipinbianhao" label="课程编号"></el-table-column>
			<el-table-column sortable prop="shipinmingcheng" label="课程名称"></el-table-column>
			<el-table-column align="center" prop="fengmiantupian" label="课程图片" width="120"
				><template slot-scope="scope"
					><el-image :src="scope.row.fengmiantupian" style="height: 70px" v-if="scope.row.fengmiantupian" /><img
						src="../../../static/images/guanli.jpg"
						style="height: 70px"
						v-else /></template
			></el-table-column>
			<el-table-column sortable prop="leibie" label="类别"></el-table-column>

			<el-table-column sortable prop="createTime" label="添加时间" width="160">
				<template slot-scope="scope">
					<div>{{ scope.row.createTime | datePipe('yyyy-MM-dd hh:mm:ss') }}</div>
				</template>
			</el-table-column>

			<el-table-column align="center" label="操作" min-width="160">
				<template slot-scope="scope">
					<el-button size="mini" type="danger" @click="addSalary(scope.$index, scope.row)">添加课程反馈</el-button>
				</template>
			</el-table-column>
		</el-table>
		<Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
	</div>
</template>

<script>
import Pagination from '@/layout/pagination/Pagination';
import {
	yingshishipinList,
	yingshishipinSave,
	yingshishipinDelete,
	yingshishipinEdit,
	yingshishipinDeleteList,
} from '@/api/yingshishipin/yingshishipinApi';
import { shipinleibieAllList, shipinleibieList } from '@/api/shipinleibie/shipinleibieApi';

import { Session } from '@/utils/storage';
export default {
	name: 'user',
	data() {
		return {
			loading: false, //是显示加载
			title: '',
			editFormVisible: false, //控制编辑页面显示与隐藏

			editForm: {},
			user: [],
			username: '',
			cx: '',
			shipinleibies: [],

			rules: {},

			formInline: {
				page: 1,
				limit: 10,
			},

			listData: [],
			yingshishipins: [],
			checkmenu: [],
			pageparm: {
				currentPage: 1,
				pageSize: 10,
				total: 0,
			},
		};
	},
	computed: {
		headers() {
			return { token: Session.get('token') };
		},
	},
	watch: {
		$route(to, from) {
			// 路由发生变化页面刷新
			this.$router.go(0);
		},
	},
	components: {
		Pagination,
	},
	created() {
		if (!Session.get('userInfo')) return false;
		this.userInfo = Session.get('userInfo');
		this.username = localStorage.getItem('username');
		this.cx = localStorage.getItem('cx');

		this.getdata(this.formInline);
		this.getAllshipinleibie({});
	},
	methods: {
		getdata(parameter) {
			yingshishipinList(parameter)
				.then((res) => {
					this.loading = false;
					if (res.success == false) {
						this.$message({
							type: 'info',
							message: res.msg,
						});
					} else {
						this.listData = res.data.list;

						// 分页赋值
						this.pageparm.currentPage = this.formInline.current;
						this.pageparm.pageSize = this.formInline.currentNum;
						this.pageparm.total = res.data.total;
					}
				})
				.catch((err) => {
					this.loading = false;
					this.$message.error('菜单加载失败，请稍后再试！');
				});
		},
		//qixuzhijixsuan3
		// 分页插件事件
		callFather(parm) {
			this.formInline.current = parm.currentPage;
			this.getdata(this.formInline);
		},
		//xia2sui1
		// 搜索事件
		search() {
			this.getdata(this.formInline);
		},
		//显示编辑界面

		addSalary(index, row) {
			this.$router.push({
				name: 'yingpingfankuiAdd',
				params: {
					id: row.id,
				},
			});
		},
		// 编辑、增加页面保存方法

		// 删除公司

		getAllshipinleibie(parameter) {
			shipinleibieList(parameter).then((res) => {
				if (res.code == '0') {
					this.shipinleibies = res.data.list;
				}
			});
		},

		// 关闭编辑、增加弹出框
	},
};
</script>

<style scoped lang="scss">
@import './index.scss';
</style>
